//
//  MoodFirstViewController.m
//  Today
//
//  Created by fanfan on 15/5/22.
//  Copyright (c) 2015年 fanfan. All rights reserved.
//

#import "MoodFirstViewController.h"

@interface MoodFirstViewController ()

@end

@implementation MoodFirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"写日记";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"iconfont-zhinenghuaxuanpinicon2"] style:UIBarButtonItemStylePlain target:self action:@selector(selectorCollect)];
    
    self.view.backgroundColor = [UIColor colorWithRed:1.000 green:0.604 blue:0.199 alpha:1.000];
    
    
    myTextView = [[UITextView alloc] init];
    myTextView.delegate = self;
    myTextView.font = [UIFont systemFontOfSize:16.0];
    // CGFloat high = [FloatTool getTextFiledHigh:16.0 :375 :myTextView.text];
    myTextView.frame = CGRectMake(0, 0, self.view.frame.size.width, MAXFLOAT);
    myTextView.backgroundColor = [UIColor colorWithRed:1.000 green:0.936 blue:0.780 alpha:1.000];
    // [myTextView sizeToFit];
        //myTextView.contentInset = UIEdgeInsetsMake(-11, -6, 0, 0);
    //myTextView.scrollEnabled = NO;
    [myTextView becomeFirstResponder];
    [self.view addSubview:myTextView];
    [myTextView release];
    
       
    // Do any additional setup after loading the view.
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"])
    {
        [textView resignFirstResponder];
        return NO; }
    return YES;
}
- (void)selectorCollect
{
    SIAlertView *alert = [[SIAlertView alloc]initWithTitle:nil andMessage:@"编辑ok?"];
    [alert addButtonWithTitle:@"完成" type:SIAlertViewButtonTypeDefault handler:^(SIAlertView *alertView) {
        [self.mySendDelegate sendContent:myTextView.text];
        if (myTextView.text.length != 0) {
            [MoodDataBaseTool insertMoodDB:myTextView.text];
        }
        
        
        [self.navigationController popViewControllerAnimated:NO];
        
    }];
    
    [alert addButtonWithTitle:@"关闭" type:SIAlertViewButtonTypeCancel handler:^(SIAlertView *alertView) {
        
    }];
    alert.transitionStyle = SIAlertViewTransitionStyleDropDown;
    [alert show];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
